package com.cy.pj.common.web;

import com.cy.pj.common.vo.JsonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zimin
 * @create 2019-07-09 11:13
 */

/**
 * Spring MVC 全局异常处理
 * @ControllerAdvice 全局异常处理类
 */
@ControllerAdvice
public class GlobalExceptionHandler {
//    private Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
    /**
     * @exceptionHandleer
     * @param e
     * @return
     */
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public JsonResult doHandleRuntimeExceotion(RuntimeException e) {
        e.printStackTrace();
        return new JsonResult(e);
    }
}
